local skel = fk.CreateSkill {
  name = "emo__youhuo",
}

Fk:loadTranslationTable{
  ["emo__youhuo"] = "诱惑",
  [":emo__youhuo"] = "准备阶段，你可以选择至多三名异性角色，同时获得这些角色各随机一张牌（优先获得类型不同的牌）。",

  ["#emo__youhuo-choose"] = "诱惑：获得至多三名异性角色各一张牌",
}

skel:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target.phase == Player.Start
    and (target == player or table.contains(target:getTableMark("@@emo__moejie"), player.id))
    and table.find(player.room:getOtherPlayers(player, false), function (p) return not p:isNude() and p.gender ~= player.gender end)
  end,
  on_cost = function (self, event, target, player, data)
    local targets = table.filter(player.room:getOtherPlayers(player), function (p) return not p:isNude() and p.gender ~= player.gender end)
    local tos = player.room:askToChoosePlayers(player, {
      min_num = 1, max_num = 3, targets = targets, skill_name = skel.name, prompt = "#emo__youhuo-choose"
    })
    if #tos > 0 then
      player.room:sortByAction(tos)
      event:setCostData(self, {tos = tos})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards, types = {}, {}
    for _, p in ipairs(event:getCostData(self).tos) do
      local gets = table.filter(p:getCardIds("he"), function (id)
        return table.every(types, function(t) return t ~= Fk:getCardById(id).type end)
      end)
      local get = #gets > 0 and table.random(gets) or table.random(p:getCardIds("he"))
      table.insertIfNeed(types, Fk:getCardById(get).type)
      table.insert(cards, get)
    end
    if #cards > 0 then
      room:obtainCard(player, cards, true, fk.ReasonPrey, player, skel.name)
    end
  end
})

return skel
